import React, { Component } from 'react'

export default class ClassTitle extends Component {
    constructor() {
        super();
        this.state = {
            count: 0
        }
    }
    componentDidMount() {
        document.title = `你已经点击了${this.state.count}次按钮`
    }
    change() {
        this.setState({
            count: this.state.count + 1
        }, ()=>{
            document.title = `你已经点击了${this.state.count}次按钮`
        })
    }
    render() {
        return (
            <div>
                <p>按钮上显示点击的次数，页面的title也显示</p>
                <button onClick={()=>this.change()}>{this.state.count}</button>
            </div>
        )
    }
}
